package com.arsl.client.view;

import com.arsl.client.event.ShowViewEvent;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class Menu extends Composite {

	private static MenuUiBinder uiBinder = GWT.create(MenuUiBinder.class);
	HandlerManager eventBus;

	public HandlerManager getEventBus() {
		return eventBus;
	}

	public void setEventBus(HandlerManager eventBus) {
		this.eventBus = eventBus;
	}

	interface MenuUiBinder extends UiBinder<Widget, Menu> {
	}

	public Menu() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@UiField
	Button btnCreateArPage;

	@UiField
	Button btnCreateContent;

	@UiField
	Button btnEditPage;

	@UiField
	Button btnManagePaper;

	@UiHandler("btnCreateArPage")
	public void onCreateArPageClick(ClickEvent event) {
		ShowViewEvent ev = new ShowViewEvent();
		ev.setArg(ShowViewEvent.VIEW_ARG, ShowViewEvent.VIEW_CREATE_AR_PAGE);
		eventBus.fireEvent(ev);

	}

	@UiHandler("btnCreateContent")
	public void onCreateContentClick(ClickEvent event) {
		ShowViewEvent ev = new ShowViewEvent();
		ev.setArg(ShowViewEvent.VIEW_ARG, ShowViewEvent.VIEW_ADD_CONTENT);
		ev.setArg(ShowViewEvent.CONTAINER, ShowViewEvent.POPUP_PANEL);
		eventBus.fireEvent(ev);

	}

	@UiHandler("btnEditPage")
	public void onEditPageClick(ClickEvent event) {
		ShowViewEvent ev = new ShowViewEvent();
		ev.setArg(ShowViewEvent.VIEW_ARG, ShowViewEvent.VIEW_PAGESELECTOR_PANEL);
		ev.setArg(ShowViewEvent.CONTAINER, ShowViewEvent.POPUP_PANEL);
		eventBus.fireEvent(ev);

	}

	@UiHandler("btnManagePaper")
	public void onManagePaperClick(ClickEvent event) {
		ShowViewEvent ev = new ShowViewEvent();
		ev.setArg(ShowViewEvent.VIEW_ARG, ShowViewEvent.VIEW_MANAGE_PAPER);
		eventBus.fireEvent(ev);

	}

	@UiHandler("btnAnalytics")
	public void onAnalyticsClick(ClickEvent event) {
		ShowViewEvent ev = new ShowViewEvent();
		ev.setArg(ShowViewEvent.VIEW_ARG, ShowViewEvent.VIEW_ANALYTICS);
		eventBus.fireEvent(ev);

	}

}
